Open
Conversation
KubEF
reviewed
Oct 12, 2025
| @@ -0,0 +1,29 @@ | |||
| from itertools import combinations | |||
|
|
|||
| if __name__ == "__main__": | |||
Collaborator
There was a problem hiding this comment.
Это лишнее. На крайний случай, нужно было релизовать основную функцию выше, а в "main" вызывать её.
Comment on lines
+19
to
+22
| coord1[0] - coord1[1] == coord2[0] - coord2[1] | ||
| ) # Проверка на одинаковую диагональ, параллельную главной | ||
| or ( | ||
| sum(coord1) == sum(coord2) |
Collaborator
There was a problem hiding this comment.
Это можно объединить в одно условие. Достаточно добавить модули
| ### Перебор: | ||
| Тут у нас сочетание из n в квадрате по n, умноженное на сочетание из n по 2. Равняется это всё, при некотором сокращении, чему-то типа (n^2)! / (2 * (n^2 - n)! * (n - 2)!). Дальше сокращать не вижу смысла, если можно с деланной уверенностью заявить, что сложность равна O((n^2)!). Она ведь равна этому? Или я не должен настооолько округлять? Если не должен, то наверное O((n^2)! / [(n^2 - n)! * n!]). | ||
| ### Рекурсия: | ||
| На каждом уровне функции будет что-то по типу n на выбор ферзя * n на фильтрацию свободных полей. Уровней всего будет n штук в худшем случае. Получается O(n^3). |
Collaborator
There was a problem hiding this comment.
Вы в цикле на каждом шаге вызываете рекурсивный вызов. И там тоже цикл. Так что нет, не $O(n^3)$)
| @@ -0,0 +1,7 @@ | |||
| # Оценка сложности: | |||
| ### Перебор: | |||
| Тут у нас сочетание из n в квадрате по n, умноженное на сочетание из n по 2. Равняется это всё, при некотором сокращении, чему-то типа (n^2)! / (2 * (n^2 - n)! * (n - 2)!). Дальше сокращать не вижу смысла, если можно с деланной уверенностью заявить, что сложность равна O((n^2)!). Она ведь равна этому? Или я не должен настооолько округлять? Если не должен, то наверное O((n^2)! / [(n^2 - n)! * n!]). | |||
Collaborator
There was a problem hiding this comment.
Вроде бы вы правы. Но тут можно было сыграть на том, что на одной строке должен быть ровно один ферзь. С этим знанием, можно достичь куда лучших результатов.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add